package zhuoyue.com.yanjiaohui.util;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import zhuoyue.com.yanjiaohui.entity.LoginEntity;
import zhuoyue.com.yanjiaohui.entity.PostRegistCallBackEntity;
import zhuoyue.com.yanjiaohui.entity.PostRegisterEntity;
import zhuoyue.com.yanjiaohui.entity.ShopOpenEntity;
import zhuoyue.com.yanjiaohui.entity.SmsBackEntity;
import zhuoyue.com.yanjiaohui.interfacepackage.INetService;
import zhuoyue.com.yanjiaohui.url.UrlConfig;

/**
 * Created by ShellJor on 2017/4/30 0030.
 * at 15:26
 */

public class NetWorkApi {
    private Retrofit mRetrofit;
    public static NetWorkApi  sNetWorkApi;
    private INetService mService;
    private Call<PostRegistCallBackEntity>mPostRegisterEntityCall;
    private Call<ShopOpenEntity>mShopOpenEntityCall;
    private Call<LoginEntity>mLoginEntityCall;
    private Call<SmsBackEntity> mSmsBackEntityCall;

    Map<String,String> code = new HashMap<>();
      //  code.put("code", "123456");
    Map<String,String> user_name= new HashMap<>();
      //  user_name.put("user_name", "1234565");
    Map<String,String> mobile = new HashMap<>();
      //  mobile.put("mobile", "13716222924");
    Map<String,String> user_pwd = new HashMap<>();
       // user_pwd.put("user_pwd", getMd5OkData("yanjiaohui"));


    public NetWorkApi() {
        mRetrofit = new Retrofit.Builder()
                .baseUrl(UrlConfig.BASEURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        mService = mRetrofit.create(INetService.class);
    }

    public static NetWorkApi
    getInstance(){
        if(sNetWorkApi==null){
            synchronized (NetWorkApi.class){
                if(sNetWorkApi==null){
                    sNetWorkApi = new NetWorkApi();
                }
            }
        }
        return sNetWorkApi;
    }

    /**
     * Post请求  @field
     */

//     public void postRegistinfo(
//              String mobile, String code,
//             String user_name, String user_pwd, String mac_id,
//             Callback<PostRegistCallBackEntity>callback){
//         mPostRegisterEntityCall=mService.postRegistData(mobile,code,user_name,user_pwd,mac_id);
//         mPostRegisterEntityCall.enqueue(callback);
//
//     }


//     public void postRegistinfo(
//             PostRegisterEntity registerEntity,
//             Callback<PostRegistCallBackEntity>callback){
//         mPostRegisterEntityCall=mService.postRegistData(registerEntity);
//         mPostRegisterEntityCall.enqueue(callback);
//     }

    public void getphonedialog( Callback<SmsBackEntity>callback){
        mSmsBackEntityCall = mService.postphoneData();
        mSmsBackEntityCall.enqueue(callback);
    }





}
